//Global
import React from "react";
import { NextPage } from "next";

//Services
import { requestToAPI } from "@/services";

//Types
import { IUser } from "@/types/types";

//Components
import { ProfilePage } from "@/components/profilePage/ProfilePage";

export async function generateMetadata() {
  try {
    const currentUser = await requestToAPI<IUser>("/currentUser", "get");

    if (currentUser) {
      return {
        title: `La Vuelta | ${currentUser.name} Profile Page`,
        description: "Created by Zhukov Matvey",
      };
    }
  } catch (error) {
    throw new Error(`${error}`);
  }
}

const Profile: NextPage = () => {
  return <ProfilePage />;
};

export default Profile;
